import { Module } from '@nestjs/common';
import { UploadService } from './upload.service';
import { UploadController } from './upload.controller';
import { MulterModule } from '@nestjs/platform-express';
import { diskStorage } from 'multer';
import { join } from 'path';

@Module({
  imports:[MulterModule.register({
    storage:diskStorage({
      destination:join(__dirname,'../assets/img'),
      filename:(req,file,cb)=>{
        const filename=file.originalname.split('.')
        const fileFormat=filename[filename.length-1]
        cb(null,`${Date.now()}.${fileFormat}`)
      }
    })
  })],
  controllers: [UploadController],
  providers: [UploadService],
})
export class UploadModule {}
